$(document).ready(function() {
    $.history.init(function(hash){
        if(hash != "") {                       
            if (typeof(waitingDiv)=='undefined') waitingDiv = new waiting();
            waitingDiv.load(document.getElementById("wrapper"), {
                waitingGif: false
            }); 
            var clearedHashArray = hash.match(/([^/]*)\/?/);
            var clearedHash = hash;
            if (clearedHashArray) clearedHash = clearedHashArray[1];
            $('#navigation li').removeClass('active');
            $('a[href="#' + clearedHash + '"]').parent().addClass('loading');
            $("#wrapper").load('/' + hash, function(){
                waitingDiv.hide();
                $('#navigation a').parent().removeClass('loading');
                $('a[href="#' + clearedHash + '"]').parent().addClass('active');
            }); 	
        }
        return false;
    });
    $('#header .logo').click(function(){
        window.location = '/';
    })
});